#include <cstdio>
#include <algorithm>
using namespace std;
int main()
{
    int num;
    scanf("%d", &num);
    getchar();
    char str[100][257] = {0};
    int i, j;
    int count;
    char c;
    for (i = 0; i < num; ++i)
    { //循环读取行，并反转字符串方便之后的比较操作
        count = 0;
        while ((c = getchar()) != '\n')
        {
            str[i][count++] = c;
        }
        reverse(str[i], str[i] + count);
    }
    int tally = 0; //记录公共字符串的长度
    char common[257] = {0};
    char com;
    for (i = 0; i <= 256; ++i)
    { //遍历比较字符串
        com = str[0][i];
        for (j = 1; j < num; ++j)
        {
            if (com != str[j][i])
                break;
        }
        if (j == num)
            common[tally++] = com;
        else
            break;
    }
    if (0 == tally)
    {
        printf("nai\n");
    }
    else
    {
        for (i = tally - 1; i >= 0; --i)
        {
            putchar(common[i]);
        }
        putchar('\n');
    }
    return 0;
}